import java.util.*;

public class Solution {

    //只出现一次的数字
    //(1) HashSet方法
    public int singleNumber(int[] nums) {
        HashSet<Integer> set = new HashSet<>();
        for(int i = 0;i < nums.length;i++){
            if(set.contains(nums[i])){
                set.remove(nums[i]);
            }else {
                set.add(nums[i]);
            }
        }

        for(int i = 0;i < nums.length;i++){
            if(set.contains(nums[i])){
                return nums[i];
            }
        }

        return -1;
    }
    // (2)按位异或^法
    public int singleNumber2(int[] nums) {
        int ret = nums[0];
        for(int i = 1;i < nums.length;i++){
            ret = ret ^ nums[i];
        }
        return ret;
    }

    //复制带随机指针的链表
    class Node {
        int val;
        Node next;
        Node random;

        public Node(int val) {
            this.val = val;
            this.next = null;
            this.random = null;
        }
    }

    public Node copyRandomList(Node head) {
        HashMap<Node,Node> map = new HashMap<>();
        Node cur = head;
        while(cur != null){
            Node node = new Node(cur.val);
            map.put(cur,node);
            cur = cur.next;
        }
        cur = head;
        while(cur != null){
            map.get(cur).next = map.get(cur.next);
            map.get(cur).random = map.get(cur.random);
            cur = cur.next;
        }
        return map.get(head);
    }

    //坏键盘打字
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNext()) { // 注意 while 处理多个 case
            String str1 = in.nextLine();
            String str2 = in.nextLine();
            func(str1,str2);
        }
    }

    public static void func(String str1,String str2){
        str1 = str1.toUpperCase();
        str2 = str2.toUpperCase();

        HashSet<Character> setReal = new HashSet<>();
        for(int i = 0;i < str2.length();i++){
            char ch = str2.charAt(i);
            setReal.add(ch);
        }

        HashSet<Character> setBroken = new HashSet<>();

        for(int i = 0;i < str1.length();i++){
            char ch = str1.charAt(i);
            if(!setReal.contains(ch) && !setBroken.contains(ch)){
                setBroken.add(ch);
                System.out.print(ch);
            }
        }
    }

    //前k个高频单词
    public List<String> topKFrequent(String[] words, int k) {
        //1.统计每个单词出现的次数
        HashMap<String,Integer> map = new HashMap<>();
        for(String word:words){
            if(map.get(word) == null){
                map.put(word,1);
            }else {
                int val = map.get(word);
                map.put(word,val + 1);
            }
        }

        //2.建立一个大小为k的小根堆
        PriorityQueue<Map.Entry<String,Integer>> minHeap = new PriorityQueue<>(new Comparator<Map.Entry<String, Integer>>() {
            @Override
            public int compare(Map.Entry<String, Integer> o1, Map.Entry<String, Integer> o2) {
                if(o1.getValue().compareTo(o2.getValue()) == 0){
                    return o2.getKey().compareTo(o1.getKey());
                }
                return o1.getValue().compareTo(o2.getValue());
            }
        });


        //遍历map
        for(Map.Entry<String,Integer> entry: map.entrySet()){
            if(minHeap.size() < k){
                minHeap.offer(entry);
            }else {
                Map.Entry<String,Integer> top = minHeap.peek();
                if(top.getValue().compareTo(entry.getValue()) < 0){//< 是因为如果后面的元素比堆顶的大就插入
                    minHeap.poll();
                    minHeap.offer(entry);
                }else if(top.getValue().compareTo(entry.getValue()) == 0){
                    if(top.getKey().compareTo(entry.getKey()) > 0){
                        minHeap.poll();
                        minHeap.offer(entry);
                    }
                }
            }
        }

        List<String> ret = new ArrayList<>();
        for (int i = 0; i < k; i++) {
            ret.add(minHeap.poll().getKey());
        }
        Collections.reverse(ret);
        return ret;
    }


}
